import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { JsonpModule, ConnectionBackend, HttpModule, Http, XHRBackend, RequestOptions } from '@angular/http';
import { InterceptedHttp } from './http.interceptor';
import { Router } from '@angular/router';

// 第三方包
import {
  MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule,
  MatCheckboxModule, MatChipsModule, MatDatepickerModule, MatDialogModule, MatExpansionModule,
  MatGridListModule, MatIconModule, MatIconRegistry, MatInputModule, MatListModule, MatMenuModule,
  MatNativeDateModule, MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule,
  MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule, MatSliderModule,
  MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule,
  MatToolbarModule, MatTooltipModule, MAT_PLACEHOLDER_GLOBAL_OPTIONS
} from '@angular/material';
import { FlexLayoutModule } from "@angular/flex-layout";
import { NgxPaginationModule } from 'ngx-pagination';
import { Util } from './util/util';
import { Highlight } from './pipes/highlight.pipe';

import { MatSnackBar } from '@angular/material';
import { UserVerifyProvider } from './util/user-verify.provider';
import { UserPageProvider } from './pages/user/user.page.provider';

import {PaginationModule} from './component/pagination/pagination.module';


@NgModule({
  declarations: [Highlight],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    CommonModule,
    FormsModule,
    JsonpModule,
    HttpModule,
    MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule, MatDialogModule, MatExpansionModule, MatGridListModule, MatIconModule, MatInputModule, MatListModule, MatMenuModule, MatNativeDateModule, MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule, MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule, MatTooltipModule,
    FlexLayoutModule,
    // ToastyModule,
    // JasperoAlertsModule,
    NgxPaginationModule,
    PaginationModule

  ],
  providers: [
    {
      provide: Http,
      useFactory: function (xhrBackend, requestOptions, matSnackBar, router) {
        return new InterceptedHttp(xhrBackend, requestOptions, matSnackBar, router);
      },
      deps: [XHRBackend, RequestOptions, MatSnackBar, Router]
    },
    { provide: MAT_PLACEHOLDER_GLOBAL_OPTIONS, useValue: { float: 'always' } },
    Util,
    Highlight,
    UserPageProvider,
    UserVerifyProvider

  ],
  exports: [
    FormsModule,
    MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule, MatDialogModule, MatExpansionModule, MatGridListModule, MatIconModule, MatInputModule, MatListModule, MatMenuModule, MatNativeDateModule, MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule, MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule, MatTooltipModule,
    FlexLayoutModule,
    // ToastyModule,
    // JasperoAlertsModule,
    NgxPaginationModule,
    Highlight,
    PaginationModule
  ]
})

export class ShareModule {
  constructor(mdIconRegistry: MatIconRegistry) {
    mdIconRegistry.registerFontClassAlias('fontawesome', 'fa');
    mdIconRegistry.setDefaultFontSetClass('fa');

  }
}
